* Use data from the May 2018 version of the Voter Study Group VOTER survey
* https://www.voterstudygroup.org/data
* and get files from:
* Replication Data for: Activating Animus: The Uniquely Social Roots of Trump Support
* https://dataverse.harvard.edu/dataset.xhtml;jsessionid=e9c7ec6b4a9ccc35743b784da827?persistentId=doi%3A10.7910%2FDVN%2FQ4VN7A&version=&q=&fileAccess=&fileTag=&fileSortField=&fileSortOrder=

use "VOTER_Survey_May18.dta"

* Run lines 9 through 173 in "ActivatingAnimus_ReplicationCode_MainText_FINAL.do"

tab ft_rep_2017
tab ft_rep_2017, nol
recode ft_rep_2017 (0/50 101/999=0) (51/100=1), gen(favGOP)
tab ft_rep_2017 favGOP, mi

tab fav_mcconnell_2018
tab fav_mcconnell_2018, nol
recode fav_mcconnell_2018 (1/2=1) (2/8=0), gen(favMCCONNELL)
tab fav_mcconnell_2018 favMCCONNELL, mi

tab fav_ryan_2018
tab fav_ryan_2018, nol
recode fav_ryan_2018 (1/2=1) (2/8=0), gen(favRYAN)
tab fav_ryan_2018 favRYAN, mi

tab fav_trump_2018
tab fav_trump_2018, nol
recode fav_trump_2018 (1/2=1) (2/8=0), gen(favTRUMP)
tab fav_trump_2018 favTRUMP, mi

tab1 pid7_baseline_clean_01 Ideo_baseline_cleaned_01 educ_baseline race_baseline religpew_baseline age2011decades female_baseline faminc_baseline_clean_01 rr_polinterest_baseline_01
recode religpew_baseline (8=12) // For some regressions, religpew_baseline=8 predicted success perfectly

xtile d10 = rr_demgroupsFT11 if (favTRUMP!=. & favGOP!=. & favMCCONNELL!=. & favRYAN!=.) & pid7_baseline_clean_01!=. & Ideo_baseline_cleaned_01!=. & educ_baseline!=. & race_baseline!=. & religpew_baseline!=. & age2011decades!=. & female_baseline!=. & faminc_baseline_clean_01!=. & rr_polinterest_baseline_01!=., nq(10)

logit favGOP       d10 pid7_baseline_clean_01 Ideo_baseline_cleaned_01 i.educ_baseline i.race_baseline i.religpew_baseline age2011decades female_baseline faminc_baseline_clean_01 rr_polinterest_baseline_01, robust
margins, at(d10=(1(1)10)) atmeans level(84) noatlegend
marginsplot, ylabel(0(0.25)1)

logit favMCCONNELL d10 pid7_baseline_clean_01 Ideo_baseline_cleaned_01 i.educ_baseline i.race_baseline i.religpew_baseline age2011decades female_baseline faminc_baseline_clean_01 rr_polinterest_baseline_01, robust
margins, at(d10=(1(1)10)) atmeans level(84) noatlegend
marginsplot, ylabel(0(0.25)1)

logit favRYAN      d10 pid7_baseline_clean_01 Ideo_baseline_cleaned_01 i.educ_baseline i.race_baseline i.religpew_baseline age2011decades female_baseline faminc_baseline_clean_01 rr_polinterest_baseline_01, robust
margins, at(d10=(1(1)10)) atmeans level(84) noatlegend
marginsplot, ylabel(0(0.25)1)

logit favTRUMP     d10 pid7_baseline_clean_01 Ideo_baseline_cleaned_01 i.educ_baseline i.race_baseline i.religpew_baseline age2011decades female_baseline faminc_baseline_clean_01 rr_polinterest_baseline_01, robust
margins, at(d10=(1(1)10)) atmeans level(84) noatlegend
marginsplot, ylabel(0(0.25)1)

tab d10 if favGOP       !=. & pid7_baseline_clean_01!=. & Ideo_baseline_cleaned_01!=. & educ_baseline!=. & race_baseline!=. & religpew_baseline!=. & age2011decades!=. & female_baseline!=. & faminc_baseline_clean_01!=. & rr_polinterest_baseline_01!=.
tab d10 if favMCCONNELL !=. & pid7_baseline_clean_01!=. & Ideo_baseline_cleaned_01!=. & educ_baseline!=. & race_baseline!=. & religpew_baseline!=. & age2011decades!=. & female_baseline!=. & faminc_baseline_clean_01!=. & rr_polinterest_baseline_01!=.
tab d10 if favRYAN      !=. & pid7_baseline_clean_01!=. & Ideo_baseline_cleaned_01!=. & educ_baseline!=. & race_baseline!=. & religpew_baseline!=. & age2011decades!=. & female_baseline!=. & faminc_baseline_clean_01!=. & rr_polinterest_baseline_01!=.
tab d10 if favTRUMP     !=. & pid7_baseline_clean_01!=. & Ideo_baseline_cleaned_01!=. & educ_baseline!=. & race_baseline!=. & religpew_baseline!=. & age2011decades!=. & female_baseline!=. & faminc_baseline_clean_01!=. & rr_polinterest_baseline_01!=.
